package com.tuanzi.loan.business.service.receipt.statistics.impl;

import com.tuanzi.loan.business.entity.extend.ExtendInfo;
import com.tuanzi.loan.business.entity.receipt.statistics.ReceiptExtendStatistics;
import com.tuanzi.loan.business.repository.receipt.statistics.ReceiptExtendStatisticsRepository;
import com.tuanzi.loan.business.service.receipt.statistics.ReceiptExtendStatisticsService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.service.CommonServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.receipt.statistics.ReceiptExtendStatisticsSearchRequest;
import com.tuanzi.loan.vo.response.receipt.statistics.ReceiptExtendStatisticsSearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Debug
@Service
@Transactional
public class ReceiptExtendStatisticsServiceImpl extends CommonServiceImpl<ReceiptExtendStatistics,Long> implements ReceiptExtendStatisticsService {

    @Autowired
    private ReceiptExtendStatisticsRepository receiptExtendStatisticsRepository;

    @Override
    protected JpaRepository<ReceiptExtendStatistics, Long> getRepository() {
        return receiptExtendStatisticsRepository;
    }

    @Override
    public Page<ReceiptExtendStatisticsSearchResponse> list(PageSearcher<ReceiptExtendStatisticsSearchRequest> pageSearcher) {
        return receiptExtendStatisticsRepository.list(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
    }

    @Override
    public List<ExtendInfo> findAllExtendInfos() {
        return receiptExtendStatisticsRepository.findAllExtendInfos();
    }

    @Override
    public Integer findOrderCountByProdIdAndChanelIdAndDate(Long productId, String channelId, Date startTime, Date endTime) {
        return receiptExtendStatisticsRepository.findOrderCountByProdIdAndChanelIdAndDate(productId, channelId, startTime, endTime);
    }

    @Override
    public Integer getNginxUV(String url, Date date) {
        return receiptExtendStatisticsRepository.getNginxUV(url,date);
    }

    @Override
    public Integer getRegisterCount(String channelId, Date startDate,Date endDate) {
        return receiptExtendStatisticsRepository.getRegisterCount(channelId,startDate,endDate);
    }
}
